import rxAjax from '../../assets/js/ajax.js';

//表单权限配置 api接口
export const LoginApi = {};

LoginApi.authUrl= '/api-uaa';
LoginApi.userUrl= '/api-user';

//登录
LoginApi.login = (parameter) => rxAjax.postForm(
    LoginApi.authUrl + '/oauth/user/token',
    parameter,{token:false}
)

//获取验证码
LoginApi.imgcode = (uuid) => rxAjax.getBlob(
    LoginApi.authUrl+'/validata/code/'+uuid
)

/**
 * 获取登录的参数配置，包括验证码，应用名称，是否需要输入租户机构
 */
LoginApi.getLoginConfig = function () {
    return rxAjax.get(LoginApi.authUrl + '/validata/getLoginConfig');
}

//获取用户信息
LoginApi.getUserInfo = () => rxAjax.get(
    LoginApi.authUrl +'/user/org/osUser/current'
)

//退出登录
LoginApi.logout = (token) => rxAjax.postUrl(
    LoginApi.authUrl+'/oauth/remove/token',
    {"token": token}
)

//获取后端用户与路由菜单信息
LoginApi.getLoginUserAndMenu = function (appKey) {
    return rxAjax.get("/api-user/user/org/menu/getFrontApp?appKey=" + appKey);
}


export  default LoginApi;
